var _util = _interopRequireDefault(require("../../../../public/utils/util")), _cardUtil = _interopRequireDefault(require("../../../../utils/card-util")), _withinmsg = _interopRequireDefault(require("../../../../public/utils/withinmsg"));

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

function _toConsumableArray(t) {
    return _arrayWithoutHoles(t) || _iterableToArray(t) || _nonIterableSpread();
}

function _nonIterableSpread() {
    throw new TypeError("Invalid attempt to spread non-iterable instance");
}

function _iterableToArray(t) {
    if (Symbol.iterator in Object(t) || "[object Arguments]" === Object.prototype.toString.call(t)) return Array.from(t);
}

function _arrayWithoutHoles(t) {
    if (Array.isArray(t)) {
        for (var e = 0, a = new Array(t.length); e < t.length; e++) a[e] = t[e];
        return a;
    }
}

var CHILD_MENU = {
    timelist: "按时间展示",
    countlist: "按频率展示",
    tracklist: "按轨迹展示"
}, TABS_SELECT_CLASSIFY = [], appData = getApp().globalData;

Component({
    properties: {
        top: String
    },
    created: function() {
        this.noMore = {}, this.offset = {};
    },
    data: {
        CHILD_MENU: Object.keys(CHILD_MENU).map(function(t) {
            return CHILD_MENU[t];
        }),
        childIndex: 0,
        datePicker: {},
        cardShown: !1,
        radarTipShown: !0,
        isOpenRadar: !0,
        dateNow: _util.default.formatLocalDate(Date.now(), "Y-M-D")
    },
    ready: function() {
        var e = this;
        [ [ "card.change", function(t) {
            return e.setData({
                card: t
            });
        } ], [ "change.radar.push", function(t) {
            return e.setData({
                isOpenRadar: t
            });
        } ] ].forEach(function(t) {
            return e.$addListener.apply(e, _toConsumableArray(t));
        }), this.init();
    },
    methods: {
        init: function() {
            TABS_SELECT_CLASSIFY.length = 0, this.setData({
                card: appData.card
            }), this.onChildChange({
                currentTarget: {
                    dataset: {
                        index: 0
                    }
                }
            }), this.checkExistCorp();
        },
        getcom: function(t) {
            var e = Object.keys(CHILD_MENU);
            return void 0 === t && (t = this.data.childIndex), this.selectComponent("#" + e[t]);
        },
        onPullDownRefresh: function() {
            this.getcom().onPullDownRefresh();
        },
        onReachBottom: function() {
            this.getcom().onReachBottom();
        },
        onChildChange: function(t) {
            var e = this, a = t.currentTarget.dataset.index;
            a = +a, this.setData({
                childIndex: a
            }, function() {
                TABS_SELECT_CLASSIFY.includes(a) || (wx.showLoading({
                    title: "加载中..."
                }), e.getcom(a).init(wx.hideLoading), TABS_SELECT_CLASSIFY.push(a));
            });
        },
        checkExistCorp: function() {
            var i = this, n = this.data.card, o = +n.receivemsg;
            _withinmsg.default.checkExistCorp(n).then(function(t) {
                var e = t.isexist, a = t.issubscribe, r = o === _cardUtil.default.RECEIVEMSG.OPEN;
                o === _cardUtil.default.RECEIVEMSG.NOTSE && (r = n.isFeeVer && e && a), i.setData({
                    isOpenRadar: r,
                    issubscribe: a
                });
            });
        },
        toggleOpenRadar: function() {
            var e = this, t = this.data, a = t.isOpenRadar;
            if (!t.issubscribe && !a) return wx.showModal({
                content: "请先关注商务雷达",
                success: function(t) {
                    t.confirm && _cardUtil.default.saveRadarIcon(e);
                },
                complete: function() {
                    return e.setData({
                        isOpenRadar: a
                    });
                }
            });
            this.openRadar();
        },
        openRadar: function() {
            var t = this.data, e = t.isOpenRadar, a = t.issubscribe;
            this.$route("/pages/radar/open/open?isopen=".concat(e, "&issubscribe=").concat(a));
        },
        closeRadarTip: function() {
            this.setData({
                radarTipShown: !1
            });
        }
    }
});